package com.fdb.efp.nls.service.impl;

import com.fdb.basic.framework.core.base.FrameworkService;
import com.fdb.efp.nls.service.dao.GzBankSettleRepayDetailFileTempDao;
import com.fdb.efp.nls.service.domain.GzBankSettleRepayDetailFileTemp;
import com.fdb.efp.nls.service.facade.GzBankSettleRepayDetailFileTempService;
import com.fdb.efp.nls.service.vo.GzBankSettleRepayDetailFileTempVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 
 * @date:2018年12月26日 下午2:50:35
 * @author:cenyj
 */
@Service("gzBankSettleRepayDetailFileTempService")
public class GzBankSettleRepayDetailFileTempServiceImpl implements GzBankSettleRepayDetailFileTempService, FrameworkService {
	private static Logger logger = LoggerFactory.getLogger(BatCircleaccServiceImpl.class);

	@Autowired
	private GzBankSettleRepayDetailFileTempDao gzBankSettleRepayDetailFileTempDao;

	@Override
	public int insert(GzBankSettleRepayDetailFileTempVO record) {
		GzBankSettleRepayDetailFileTemp gzBankSettleRepayDetailFileTempVO = new GzBankSettleRepayDetailFileTemp();
		logger.debug("当前新增数据为:" + gzBankSettleRepayDetailFileTempVO.toString());
		int num = 0;
		try {
			GzBankSettleRepayDetailFileTemp batCircleacc = new GzBankSettleRepayDetailFileTemp();
			beanCopy(gzBankSettleRepayDetailFileTempVO, record);
			num = gzBankSettleRepayDetailFileTempDao.insert(batCircleacc);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:" + num);
		return num;
	}

	@Override
	public int insertSelective(GzBankSettleRepayDetailFileTempVO record) {
		GzBankSettleRepayDetailFileTemp gzBankSettleRepayDetailFileTempVO = new GzBankSettleRepayDetailFileTemp();
		logger.debug("当前新增数据为:" + gzBankSettleRepayDetailFileTempVO.toString());
		int num = 0;
		try {
			GzBankSettleRepayDetailFileTemp batCircleacc = new GzBankSettleRepayDetailFileTemp();
			beanCopy(gzBankSettleRepayDetailFileTempVO, record);
			num = gzBankSettleRepayDetailFileTempDao.insertSelective(batCircleacc);
		} catch (Exception e) {
			logger.error("新增数据发生异常!", e);
			num = -1;
		}
		logger.debug("当前新增数据条数为:" + num);
		return num;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<GzBankSettleRepayDetailFileTempVO> getGzBankSettleRepayDetailFileTempList() {
		List<GzBankSettleRepayDetailFileTempVO> list = null;
		try {
			List<GzBankSettleRepayDetailFileTemp> listGzBankSettleRepayDetailFileTemps = gzBankSettleRepayDetailFileTempDao
					.getGzBankSettleRepayDetailFileTempList();
			list = (List<GzBankSettleRepayDetailFileTempVO>) beansCopy(listGzBankSettleRepayDetailFileTemps,
					GzBankSettleRepayDetailFileTempVO.class);
			logger.info("查询数据成功！结果为：" + list);
		} catch (Exception e) {
			e.printStackTrace();
			logger.debug("查询异常！" + e.getMessage());
		}
		return list;
	}

	/**
	 *需求编号：【2019D1204】（马上账务文件同步分页处理）
	 *问题编号：【2019D1204】（马上账务文件同步分页处理）
	 *开发人员：【ludayong】
	 *创建日期：【2019/11/27 11:31】
	 *功能描述：分页查询马上理赔还款明细临时表信息
	 *修改日期：【2019/11/27 11:31】
	 *修改描述：
	 */
	@Override
	public List<GzBankSettleRepayDetailFileTempVO> queryByPage(GzBankSettleRepayDetailFileTempVO gzBankSettleRepayDetailFileTempVO) {
		String msg1 = "分页查询理赔还款明细临时表";
		logger.debug(msg1, "message {}");
		List<GzBankSettleRepayDetailFileTempVO> list = null;
		try {
			List<GzBankSettleRepayDetailFileTemp> listGzBankSettleRepayDetailFileTemps = gzBankSettleRepayDetailFileTempDao.queryByPage(gzBankSettleRepayDetailFileTempVO);
			list = (List<GzBankSettleRepayDetailFileTempVO>) beansCopy(listGzBankSettleRepayDetailFileTemps,
					GzBankSettleRepayDetailFileTempVO.class);
		} catch (Exception e) {
			logger.error("查询数据发生异常!", e);
		}
		if(list != null) {
			String msg2 = "查询的数据为大小为 " + list.size();
			logger.debug(msg2, "message {}");
		}
		return list;
	}

	/**
	 *需求编号：【2019D1204】（马上账务文件同步分页处理）
	 *问题编号：【2019D1204】（马上账务文件同步分页处理）
	 *开发人员：【ludayong】
	 *创建日期：【2019/11/27 11:31】
	 *功能描述：统计马上理赔还款明细临时表数据量
	 *修改日期：【2019/11/27 11:31】
	 *修改描述：
	 */
	@Override
	public int queryCount() {
		String msg1 = "查询【理赔还款明细临时表】表中数据量大小";
		logger.debug(msg1, "message {}");
		int num = 0;
		try {
			num = gzBankSettleRepayDetailFileTempDao.queryCount();
		} catch (Exception e) {
			String msg2 = "查询【理赔还款明细临时表】表中数据量大小出错" + e;
			logger.debug(msg2, "message {}");
			num = -1;
		}
		return num;
	}

}
